/*
    Project:        Home Power Control
    File:           main.cpp
    Author:         christian@karunamusic.at
    Date:           11.2014
    Description:    Mainclass (HPC) and main-function.
 */

#include <iostream>
#include <exception>
#include "version.h"
#include "globals.h"
#include "HPCStation.h"

namespace av = AutoVersion;
using namespace std;

int main( int argc, char **argv )
{
    PROFILE_THIS;

    time_t now = time(0);
    struct tm tstruct;
    char buf[80];

    tstruct = *localtime( &now );
    strftime( buf,sizeof(buf),"%d.%m.%Y %X",&tstruct );

    cout << endl
         << "****************************" << endl
         << "* [H]ome [P]ower [C]ontrol *" << endl
         << "* [press 'ctrl-d' to exit] *" << endl
         << "****************************" << endl
         << "  v" << av::FULLVERSION_STRING << av::STATUS_SHORT << endl << "started: " << buf << endl;

    try
    {
        HPCStation *hpc = new HPCStation( argc,argv );

        char c;
        while ( cin >> c ) {}
        cout << "shutdown hpc..." << endl;
        delete hpc;
    }
    catch ( exception &e )
    {
        LOG(fatal, e.what() );
        return -1;
    }

    return 0;
}
